package com.jt.safe.ui.staff.activity

import androidx.core.content.ContextCompat
import com.jt.safe.R
import com.jt.safe.base.BaseActivity
import com.jt.safe.ui.staff.fragment.OffDutyRecordFragment
import com.jt.safe.ui.staff.fragment.TasksOfNursingPostFragment
import com.jt.safe.viewmodel.NullViewModel
import kotlinx.android.synthetic.main.activity_staff_main.*

class StaffMainActivity : BaseActivity<NullViewModel>() {

    override val layoutId: Int
        get() = R.layout.activity_staff_main

    override fun initView() {
        val newInstance1 = TasksOfNursingPostFragment.newInstance()
        val newInstance2 = OffDutyRecordFragment.newInstance()

        val beginTransaction = supportFragmentManager.beginTransaction()
        beginTransaction.add(R.id.fm, newInstance1)
        beginTransaction.add(R.id.fm, newInstance2)

        beginTransaction.hide(newInstance2)
        beginTransaction.commitAllowingStateLoss()

        rl1.setOnClickListener {
            val beginTransaction1 = supportFragmentManager.beginTransaction()
            beginTransaction1.show(newInstance1)
            beginTransaction1.hide(newInstance2)
            beginTransaction1.commitAllowingStateLoss()

            iv1.setImageResource(R.mipmap.parent_recruit_y)
            tv1.setTextColor(ContextCompat.getColor(this, R.color.theme))
            iv4.setImageResource(R.mipmap.parent_message_n)
            tv4.setTextColor(ContextCompat.getColor(this, R.color.tv))
        }

        rl4.setOnClickListener {
            val beginTransaction1 = supportFragmentManager.beginTransaction()
            beginTransaction1.hide(newInstance1)
            beginTransaction1.show(newInstance2)
            beginTransaction1.commitAllowingStateLoss()

            iv1.setImageResource(R.mipmap.parent_recruit_n)
            tv1.setTextColor(ContextCompat.getColor(this, R.color.tv))
            iv4.setImageResource(R.mipmap.parent_message_y)
            tv4.setTextColor(ContextCompat.getColor(this, R.color.theme))
        }
    }

    override fun createObserver() {

    }
}
